<template>
  <select-all :all-select-list="roleList" v-model="Range" />
</template>

<script>
import SelectAll from '@/components/SelectAll'
import { rolePreset } from '@/api/role'
export default {
  name: 'Role',
  components: {
    SelectAll
  },
  data() {
    return {
      Range: [],
      roleList: []
    }
  },
  watch: {
    Range() {
      this.$emit('input', this.Range)
    }
  },
  created() {
    this.getSelect()
  },
  methods: {
    getSelect() {
      rolePreset({}).then(res => {
        const options = []
        for (const key in res.data.available) {
          options.push({ name: '全选/取消', CName: res.data.available[key], value: key })
        }
        this.roleList = options
      }, err => {
        this.$message({ type: 'error', message: err.response.data.msg })
      })
    }
  }
}
</script>
